package com.cashmama.market.api.domain.utils;

import com.cashmama.market.api.infras.utils.StringUtils;

/**
 * @program: market-api
 * @description
 * @author: frank
 * @create: 2020-09-30 15:22
 **/
public class Amazon2OssUtils {

    public static String convertOssUrl(String amazonS3Url){
        if(StringUtils.isEmpty(amazonS3Url)){
            return amazonS3Url;
        }
        if(amazonS3Url.contains("https://cashmama.s3.ap-south-1.amazonaws.com")){
            amazonS3Url = amazonS3Url.replace("https://cashmama.s3.ap-south-1.amazonaws.com", "http://cashmama-oss-pro.cashmama.in");
        }else if(amazonS3Url.contains("http://cashmama.s3.ap-south-1.amazonaws.com")){
            amazonS3Url = amazonS3Url.replace("http://cashmama.s3.ap-south-1.amazonaws.com", "http://cashmama-oss-pro.cashmama.in");
        }
        return amazonS3Url  + "?x-oss-process=image/resize,limit_0,m_mfit,w_400,h_400/quality,q_100";
    }

    public static void main(String[] args) {
        System.out.println(convertOssUrl("http://cashmama.s3.ap-south-1.amazonaws.com/moveClientSpace/2020093099009729104510/95ee893c30c14b66a7c9e5e358f9c956_B"));
    }
}
